package com.tangyuan.user.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tangyuan.common.constant.RedisConstant;
import com.tangyuan.common.result.Result;
import com.tangyuan.model.User;
import com.tangyuan.common.util.CommStatus;
import com.tangyuan.user.mapper.UserSearchMapper;
import com.tangyuan.user.service.UserSearchService;
import com.tangyuan.vo.SearchUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserInfoSearchImpl implements UserSearchService {

    @Autowired
    UserSearchMapper userSearchMapper ;

    @Override
    public Result userSearch(Integer pageNum, Integer pageSize,String  name,String token) {
        PageHelper.startPage(pageNum,pageSize);
        User user = CommStatus.getUser(token);
        Long userId = user.getId();
        List<SearchUserVo> list = userSearchMapper.searchUserInfo(name, userId);
        return Result.ok(new PageInfo<>(list));
    }
}
